<?php


namespace App\Model;

use PhalApi\Model\NotORMModel as NotORM;


class Order extends NotORM
{
    public function getOrderList()
    {
        return $this->getORM()->fetchAll();
    }

    public function getOrderInfoByUid($user_id)
    {
        return $this->getORM()->where('uid', $user_id)->fetchAll();
    }

    public function insertOrderInfo($order_id, $order_uaid, $order_uid,  $order_money)
    {
        $date = date('Y-m-d h:i:s', time());
        $data = array('id' => $order_id, 'uaid' => $order_uaid, 'uid' => $order_uid, 'createtime' => $date, 'money' => $order_money, 'flag' => 1);
        $orm = $this->getORM();
        $orm->insert($data);
        return $orm->insert_id() + 1;
    }

    public function deleteOrderInfoByOid($order_id)
    {
        return $this->getORM()->where('id', $order_id)->delete();
    }

    public function updateOrderInfoByOid($order_id)
    {
        $data = array('flag' => 2);
        return $this->getORM()->where('id', $order_id)->update($data);
    }

    public function likeQueryByOrderId($like_orderId)
    {
        return $this->getORM()->where('id LIKE ?', "%$like_orderId%")->fetchAll();

    }

    public function getByOrderFlag($orderFlag)
    {
        return $this->getORM()->where('flag', $orderFlag)->fetchAll();

    }

    public function getByOrderId($orderId)
    {
        return $this->getORM()->where('id', $orderId)->fetchAll();
    }
}